package com.cobra.consumer;

import com.cobra.DemoService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;

import java.io.IOException;
import java.util.Map;

//初始化的默认服务
@EnableAutoConfiguration
public class DefaultDubboConsumerDemo {
    @Reference(version = "default")
    private DemoService demoService;
    @Reference(version = "default1")
    private DemoService demoService1;
    public static void main(String[] args) throws IOException {
        ConfigurableApplicationContext context = SpringApplication.run(DefaultDubboConsumerDemo.class);
        Map<String, DemoService> beansOfType = context.getBeansOfType(DemoService.class);
        beansOfType.forEach((k,v)->{
            System.out.println(k);
        });
        DemoService demoService = context.getBean("@Reference(version=default) com.cobra.DemoService",DemoService.class);

        String result = demoService.sayHello("cobra");
        System.out.println(result);
    }


}
